<?php 
$Content = QContext::instance();
$base_url = $Content->requestUDI();
$search = $base_url;
$search['action'] = 'search';
$hangup = $base_url;
$hangup['action'] = 'hangup';

?>

<form id="pagerForm" method="get" action="<?php echo url($base_url,null,null,array('mode'=>'standard'));?>">
		<input type="hidden" name="pageNum" value="<?php echo $pagination['current'];?>" /> <!--【必须】value=1可以写死-->
		<input type="hidden" name="numPerPage" value="<?php echo $pagination['page_size'];?>" /> <!--【可选】每页显示多少条-->
		<input type="hidden" name="orderField" value="<?php echo $orderField;?>" />
		<input type="hidden" name="orderDirection" value="<?php echo $orderDirection;?>" />
</form>

<div class="pageHeader">
	<form rel="pagerForm" onsubmit="return navTabSearch(this);" action="<?php echo url($base_url,null,null,array('mode'=>'standard'));?>" method="get">
	<div class="searchBar">
		<ul class="searchContent">
			<li>
				<label>被叫：</label>
				<input type="text" name="called" value="<?php echo isset($param['"called"'])?$param['called']:'';?>"/>
				<input type="hidden" name="_querymethod[called]" value="like">
			</li>
			<li>
				<label>状态：</label>
			<select class="combox" name="state">
				<option value="">全部状态</option>
				<option value="1" <?php echo isset($param['state'])?$param['state']=='1'?'selected':'':'';?>>通话</option>
				<option value="0" <?php echo isset($param['state'])?$param['state']=='0'?'selected':'':'';?>>呼叫</option>
			</select>
			</li>
			<li>
				<label>账号：</label>
				<input type="text" name="acct" value="<?php echo isset($param['acct'])?$param['acct']:'';?>"/>
			</li>
		</ul>
		
		<div class="subBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>
			</ul>
		</div>
	</div>
	</form>
</div>
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
			
		<?php 
		$data = QDB::getConn('fscall')->execute("select count(*) as c,host from call_status group by host")->fetchAll();
		$data = Helper_Array::toHashmap($data, 'host','c');
		foreach ($data as $kk=>$tt)
		{
			echo "{$kk} 系统当前:{$tt}线    |";
		}
		?>	
			
		</ul>
	</div>
	<table class="table" width="1200" layoutH="138">
		<thead>
			<tr>
				<th width="3%"><input type="checkbox" group="ids[]" class="checkboxCtrl"></th>
				
				<th width="5%" >帐号</th>
				<th width="5%" >代理</th>
				<th width="5%" >中继IP</th>
				<th width="5%" align="center" >主叫</th>
				<th width="5%" >被叫</th>
				<th width="5%" >业务</th>
				<th width="5%" >	状态</th>
				<th width="10%" >开始</th>
				<th width="5%" >应答</th>
				<th width="10%" >时长(秒)</th>
				<th width="10%" >操作</th>
				
			</tr>
		</thead>
		<tbody>
		
			<?php foreach ($item as $k=>$v):?>
		
			<tr target="id" rel="<?php echo $v->id?>"
			<?php
			if ($v->calltype == 1)
			{
				echo 'bgcolor="#F3F3F3"';
			}else if ($v->calltype == 2)
			{
				echo 'bgcolor="#CC00FF"';
			}
			?>
			
			>
				<td><input name="ids[]" value="<?php echo $v->id?>" type="checkbox"></td>
				
				<td><?php 
				echo $v->acct;
				?></td>
				<td>
					<?php 
					$user = Acctuser::find('acctname = ?',$v->acct)->getOne();
					echo $user->agent->acctname;
					?>
				</td>
				<td><?php echo $v->ip;?></td>
				<td><?php echo $v->caller;?></td>
				<td><?php echo $v->called;?></td>
				<td><?php 
				
				echo Calllist::getCallTypeStr($v->calltype);
				?></td>
				<td>
				<?php 
				$run_times =0;
				
				if ($v->state == 'early' || $v->state == 'ring')
				{
					echo '振铃';
					$run_times = 0;
				}else if($v->state == 'answered'){
					$run_times = intval(time()-strtotime($v->answer_time));
					echo '<script>addRow("val_'.$v->id.'")</script>';
				}
				?>
				<?php echo $v->state == 'early' ? '呼叫':'通话';?></td>
				<td><?php echo $v->create_time;?></td>
				<td><?php echo $v->answer_time;?></td>
				<td><span id="val_<?php echo $v->id;?>"><?php echo $run_times;?></span></td>
				<td><a href="<?php echo url('system/hangup',array('id'=>$v->id))?>" target="ajaxTodo" title="确定要挂断吗?">挂断</a></td>
			</tr>
			<?php endforeach;?>
		</tbody>
	</table>
	<div class="panelBar">
			<div class="pages">
			<span>显示</span>
			<select name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
				<option value="20" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==20)echo 'selected=selected';?>>20</option>
				<option value="50" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==50)echo 'selected=selected';?>>50</option>
				<option value="100" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==100)echo 'selected=selected';?>>100</option>
				<option value="200" <?php if(isset($param['numPerPage'])&&$param['numPerPage']==200)echo 'selected=selected';?>>200</option>
			</select>
				<span>共 <?php echo $pagination['record_count'];?> 条</span>
			</div>
		
		<div class="pagination" targetType="navTab" totalCount="<?php echo $pagination['record_count'];?>" numPerPage="<?php echo $pagination['page_size'];?>" pageNumShown="10" currentPage="<?php echo $pagination['current'];?>" ></div>

	</div>
</div>
<script>
if (isok == false)
{
	setInterval('dealyShow()',1000);
	}

</script>